FROM golang:1.17.0-alpine3.14 as builder

WORKDIR /work

COPY ./ /work

ENV GOPROXY=https://goproxy.io,direct
ENV GO111MODULE on

RUN go mod download

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GOARM=6 go build -ldflags '-w -s' -o open_api_server asoul-fan/museum-api/cmd/open_api

FROM alpine as prod

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
RUN apk update --no-cache && apk add --no-cache ca-certificates tzdata
ENV TZ Asia/Shanghai

COPY --from=builder /work/open_api_server ./

EXPOSE 9527

CMD ["./open_api_server", "-f", "configs/config.yml"]
